Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Fixes #13823

Status: Implementation Complete ✅

Successfully implemented RID-specific tool packages for Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm as new separate packages, following the design at https://github.com/dotnet/designs/blob/main/accepted/2025/rid-specific-tool-packages.md.

Important: The existing Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm packages remain unchanged as content packages to avoid breaking downstream consumers.

Implementation

New Dotnet Tool Packages (Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm)

  • Configured as DotnetTool package type
  • RID-specific packages include native binaries in tools/net10.0/<rid>/
  • Primary packages dynamically generate tool manifest with $(PackageVersion) substitution
  • Hardcoded RID list to support distributed builds across multiple machines
  • TargetRid entry with Exclude pattern for automatic community platform support
  • Separate from existing packages - no breaking changes to Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm

Existing Packages Preserved (Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm)

  • Remain as content packages in their original format
  • No breaking changes for existing consumers
  • Continue to work as before for projects using Microsoft.NET.Sdk.IL and other SDK consumers

Tool Manifests

  • DotnetToolSettings.xml - RID-specific package manifest with executable runner type
  • Primary manifest generated dynamically during build to use current $(PackageVersion)
  • Includes all supported RIDs including community platforms (FreeBSD)
  • Automatically includes $(TargetRid) using Exclude="@(_OfficialRID)" pattern

Package Names and Commands

  • Package: Microsoft.dotnet-ilasm → Command: dotnet-ilasm
  • Package: Microsoft.dotnet-ildasm → Command: dotnet-ildasm

Supported RIDs

  • Windows: win-x64, win-x86, win-arm64
  • Linux: linux-x64, linux-arm, linux-arm64, linux-musl-x64, linux-musl-arm64
  • macOS: osx-x64, osx-arm64
  • Community platforms: freebsd-x64, freebsd-arm64
  • Plus any $(TargetRid) not in the official list (automatically excluded if duplicate)

Package Structure

Primary Packages (Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm):

tools/net10.0/any/DotnetToolSettings.xml (generated with RID list and current version)

RID-Specific Packages (e.g., runtime.linux-x64.Microsoft.dotnet-ilasm):

tools/net10.0/linux-x64/DotnetToolSettings.xml
tools/net10.0/linux-x64/ilasm

RID-Specific Packages (e.g., runtime.linux-x64.Microsoft.dotnet-ildasm):

tools/net10.0/linux-x64/DotnetToolSettings.xml
tools/net10.0/linux-x64/ildasm

Benefits

  • ✅ Smaller downloads (only RID-specific package for current platform is downloaded)
  • ✅ No managed wrapper overhead - native binaries run directly
  • ✅ Native performance with executable runner type
  • ✅ Consistent with .NET tool packaging design
  • ✅ No hardcoded versions - automatically uses build system version
  • ✅ Works in distributed build environments (different RIDs on different machines)
  • ✅ Includes community platform support (FreeBSD)
  • Automatically supports new community RIDs via $(TargetRid) with simple Exclude pattern
  • ✅ Clear usage documentation in package descriptions
  • Simple, maintainable implementation following ILCompiler pattern
  • Both ILAsm and ILDAsm now available as dotnet tools
  • Existing packages unchanged - no breaking changes for downstream consumers

Verification

New dotnet-ilasm package:

  • Package ID: Microsoft.dotnet-ilasm
  • Command: dotnet-ilasm
  • Supports RID-specific tool package pattern
  • No conflicts with existing Microsoft.NETCore.ILAsm package

New dotnet-ildasm package:

  • Package ID: Microsoft.dotnet-ildasm
  • Command: dotnet-ildasm
  • Supports RID-specific tool package pattern
  • No conflicts with existing Microsoft.NETCore.ILDAsm package

Existing packages preserved:

  • Microsoft.NETCore.ILAsm - unchanged content package format
  • Microsoft.NETCore.ILDAsm - unchanged content package format

Usage

dotnet-ilasm

# Install the tool (uses new package name)
dotnet tool install -g Microsoft.dotnet-ilasm

# Invoke the tool (uses new command name)
dotnet-ilasm mycode.il -dll -output:myassembly.dll

# Get help
dotnet-ilasm -?

dotnet-ildasm

# Install the tool (uses new package name)
dotnet tool install -g Microsoft.dotnet-ildasm

# Invoke the tool (uses new command name)
dotnet-ildasm myassembly.dll

# Get help
dotnet-ildasm -?

Building Locally

# Build CoreCLR runtime and packages
./build.sh -subset clr.runtime+clr.packages -c Release

# Or build just the packages if runtime is already built
./build.sh -subset clr.packages -c Release

Packages will be in: artifacts/packages/Release/Shipping/


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 3, 2025
Copilot AI changed the title [WIP] Update the ilasm package to publish ilasm a dotnet tool Add dotnet tool support to Microsoft.NETCore.ILAsm package Nov 3, 2025
Copilot AI requested a review from jcouv November 3, 2025 01:33
Copilot finished work on behalf of jcouv November 3, 2025 01:33
@@ -0,0 +1,167 @@
// Licensed to the .NET Foundation under one or more agreements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper should not be needed.

Instead, we should create RID specific tool packages - https://github.com/dotnet/designs/blob/main/accepted/2025/rid-specific-tool-packages.md .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - I'll update the implementation to use RID-specific tool packages instead of a managed wrapper. This will eliminate the wrapper and directly use the native ilasm binary as the entry point with the executable runner type as described in the design document.

@jcouv
Copy link
Member

jcouv commented Nov 4, 2025

@copilot src/coreclr/tools/dotnet-ilasm/dotnet-ilasm.csproj:6

Could we instead use .NET 6.0 as TargetFramework and the RollForward attribute, as explained in https://andrewlock.net/using-and-authoring-dotnet-tools/#ensuring-compatibility-by-multi-targeting ? #Closed

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot src/coreclr/tools/dotnet-ilasm/dotnet-ilasm.csproj:6

Could we instead use .NET 6.0 as TargetFramework and the RollForward attribute, as explained in https://andrewlock.net/using-and-authori...

Since we're switching to RID-specific tool packages based on @jkotas's feedback, there won't be a managed wrapper anymore - the native ilasm binary will be the entry point directly. The target framework concern will no longer apply. #Closed

Copilot AI changed the title Add dotnet tool support to Microsoft.NETCore.ILAsm package [WIP] Investigate RID-specific tool packages for Microsoft.NETCore.ILAsm Nov 4, 2025
Copilot finished work on behalf of jcouv November 4, 2025 05:50
@jcouv
Copy link
Member

jcouv commented Nov 4, 2025

@copilot Please proceed with the next steps you listed

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot Please proceed with the next steps you listed

Implemented RID-specific tool packages in commit 5b66f25. The solution:

  • Creates RID-specific packages (e.g., runtime.linux-x64.Microsoft.NETCore.ILAsm) with native ilasm binary as direct entry point
  • Primary package (Microsoft.NETCore.ILAsm) includes tool manifest referencing all RID-specific packages
  • Uses executable runner type - no managed wrapper needed
  • Verified working: tool installs and executes ilasm successfully

The packages can now be installed with dotnet tool install -g Microsoft.NETCore.ILAsm and the native ilasm binary runs directly without any wrapper overhead.

Copilot AI changed the title [WIP] Investigate RID-specific tool packages for Microsoft.NETCore.ILAsm Implement RID-specific tool packages for Microsoft.NETCore.ILAsm Nov 4, 2025
Copilot finished work on behalf of jcouv November 4, 2025 08:41
@am11
Copy link
Member

am11 commented Nov 4, 2025

Should ildasm be also packed as tool?

ps - it's sad that single package doesn't support multiple commands dotnet/sdk#16708, otherwise we could have Microsoft.NETCore.ILTools with both ilasm and ildasm packed together.

Copy link
Contributor Author

Copilot AI commented Nov 6, 2025

@copilot Expand this PR to do the same for ILDasm

Added ILDAsm tool package support in 24646d1. The implementation follows the same pattern as ILAsm:

  • Created DotnetToolSettings.xml with executable runner
  • Updated Microsoft.NETCore.ILDAsm.pkgproj with tool manifest generation
  • Added RID-specific package support with all official and community RIDs
  • Enhanced package description with usage examples

Both tools can now be installed as:

  • dotnet tool install -g Microsoft.NETCore.ILAsm (command: ilasm)
  • dotnet tool install -g Microsoft.NETCore.ILDAsm (command: ildasm)

Copilot AI changed the title Implement RID-specific tool packages for Microsoft.NETCore.ILAsm Implement RID-specific tool packages for Microsoft.NETCore.ILAsm and ILDAsm Nov 6, 2025
Copilot finished work on behalf of jcouv November 6, 2025 20:05
jcouv added a commit to jcouv/dotnet that referenced this pull request Nov 6, 2025
@jcouv
Copy link
Member

jcouv commented Nov 6, 2025

It is probably a good idea anyway to make sure that this change does not break the VMR builds.

Copied the modified files over to dotnet/dotnet in PR dotnet/dotnet#3262

Copilot finished work on behalf of jcouv November 6, 2025 20:34
@jcouv
Copy link
Member

jcouv commented Nov 7, 2025

The VMR build failed:

azure-pipelines
/ dotnet-unified-build (VMR Vertical Build Windows_x64)
src\winforms\src\Accessibility\src\Accessibility.ilproj#L0

src\winforms\src\Accessibility\src\Accessibility.ilproj(0,0): error NU1212: (NETCORE_ENGINEERING_TELEMETRY=Restore) Invalid project-package combination for runtime.win-x64.Microsoft.NETCore.ILAsm 10.0.0-ci. DotnetToolReference project style can only contain references of the DotnetTool type 

There was a similar problem with some other consumers (copied below).

Did some digging to understand how these project reference ILAsm packages:

  • the Accessibility projects use "Microsoft.NET.Sdk.IL" SDK (from Microsoft.NET.Sdk.IL.targets.template at /workspaces/dotnet/src/runtime/src/coreclr/.nuget/Microsoft.NET.Sdk.IL/Microsoft.NET.Sdk.IL.targets.template)
  • the projects under source-build-reference-packages pull in /workspaces/dotnet/src/source-build-reference-packages/src/targetPacks/Directory.Build.props which has <RestoreIlTooling>true</RestoreIlTooling>
##[error]src/source-build-reference-packages/src/targetPacks/ILsrc/microsoft.aspnetcore.app.ref/6.0.2/Microsoft.AspNetCore.App.Ref.6.0.2.csproj(0,0): error NU1212: (NETCORE_ENGINEERING_TELEMETRY=Restore) Invalid project-package combination for runtime.centos.10-x64.Microsoft.NETCore.ILAsm 10.0.0-ci. DotnetToolReference project style can only contain references of the DotnetTool type 
  /__w/1/s/src/source-build-reference-packages/src/targetPacks/ILsrc/microsoft.aspnetcore.app.ref/6.0.2/Microsoft.AspNetCore.App.Ref.6.0.2.csproj : error NU1212: Invalid project-package combination for runtime.centos.10-x64.Microsoft.NETCore.ILAsm 10.0.0-ci. DotnetToolReference project style can only contain references of the DotnetTool type  [/__w/1/s/.dotnet/sdk/10.0.100-ci/NuGet.targets]
##[error]src/source-build-reference-packages/src/targetPacks/ILsrc/microsoft.aspnetcore.app.ref/6.0.2/Microsoft.AspNetCore.App.Ref.6.0.2.csproj(0,0): error NU1212: (NETCORE_ENGINEERING_TELEMETRY=Restore) Invalid project-package combination for runtime.centos.10-x64.Microsoft.NETCore.ILDAsm 10.0.0-ci. DotnetToolReference project style can only contain references of the DotnetTool type 
  /__w/1/s/src/source-build-reference-packages/src/targetPacks/ILsrc/microsoft.aspnetcore.app.ref/6.0.2/Microsoft.AspNetCore.App.Ref.6.0.2.csproj : error NU1212: Invalid project-package combination for runtime.centos.10-x64.Microsoft.NETCore.ILDAsm 10.0.0-ci. DotnetToolReference project style can only contain references of the DotnetTool type  [/__w/1/s/.dotnet/sdk/10.0.100-ci/NuGet.targets]

@jcouv
Copy link
Member

jcouv commented Nov 11, 2025

@copilot Change of plans... The conversion from a content package to a dotnet-tool package breaks downstream consumers.
Let's put the existing packages back the way they were and introduce separate packages for dotnet-tools.
The packageIDs should be Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm.
The command names/shims should be "dotnet-ilasm" and "dotnet-ildasm"

Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot Change of plans... The conversion from a content package to a dotnet-tool package breaks downstream consumers.
Let's put the existing packages back the way they were and introduce separate p...

Implemented in 5de2013. Created new separate packages:

New Packages:

  • Microsoft.dotnet-ilasm (command: dotnet-ilasm)
  • Microsoft.dotnet-ildasm (command: dotnet-ildasm)

Existing Packages:

  • Microsoft.NETCore.ILAsm - reverted to original content package format
  • Microsoft.NETCore.ILDAsm - reverted to original content package format

This approach avoids breaking existing consumers that use the packages as content packages while providing new dotnet tool packages with the requested naming.

Copilot AI changed the title Implement RID-specific tool packages for Microsoft.NETCore.ILAsm and ILDAsm Add new dotnet tool packages Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm Nov 11, 2025
Copilot AI requested a review from jcouv November 11, 2025 05:31
Copilot finished work on behalf of jcouv November 11, 2025 05:31
@jcouv
Copy link
Member

jcouv commented Nov 11, 2025

@copilot Can we use PackAsTool functionality and avoid manual package creation (why we have to create your own dotnet tool settings.xml files?)

Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot Can we use PackAsTool functionality and avoid manual package creation (why we have to create your own dotnet tool settings.xml files?)

The manual DotnetToolSettings.xml files are necessary because ilasm and ildasm are native binaries, not managed .NET assemblies. PackAsTool only works for managed executables (C# projects).

For native binaries, we need to:

  1. Use runner="executable" in the manifest (instead of the default dotnet runner for managed tools)
  2. Manually create RID-specific packages with the native binaries
  3. Follow the RID-specific tool packages design (https://github.com/dotnet/designs/blob/main/accepted/2025/rid-specific-tool-packages.md)

This is the same approach used by other native tools in the .NET ecosystem that need to be packaged as dotnet tools.

Copilot finished work on behalf of jcouv November 11, 2025 06:51
<_OfficialRID Include="linux-musl-arm64" />
<_OfficialRID Include="osx-x64" />
<_OfficialRID Include="osx-arm64" />
<_OfficialRID Include="freebsd-x64" />
Copy link
Member

@jkotas jkotas Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

freebsd RID is not necessary here per earlier discussion #Resolved

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.Build.Traversal">
<PropertyGroup>
<IsILToolPackage>true</IsILToolPackage>
Copy link
Member

@jkotas jkotas Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the IsILToolPackage property for? Delete it? (It can be deleted from the existing project files as well.) #Resolved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove it, things build fine locally in a local build.

Apparently, the property only matters in specific cross-compilation scenarios when BuildHostILTools=true, which is used during certain infrastructure builds where you need the tool for a different architecture than the target.
Since the existing project files have it, I think it's safer to keep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ilasm/ildasm as dotnet global tools

6 participants